package com.cw1.principle.segregation1;

/**
 * 单一原则的实现
 * @author Administrator
 */
public class SingleResponsibility2 {
    public static void main(String[] args) {
        RoadVehicle roadVehicle = new RoadVehicle();
        roadVehicle.run("汽车");
        roadVehicle.run("摩托车");

        AirVehicle airVehicle = new AirVehicle();
        airVehicle.run("飞机");
    }
}

/**
 * 方案二：遵守了单一原则
 * 缺点：改动大，将类进行了分解，修改客户端
 * 改进：直接修改Vehicle类，改动代码较少
 */
class RoadVehicle{
    public void run(String vehicle){
        System.out.println(vehicle + "在路上跑。。。");
    }
}

class AirVehicle{
    public void run(String vehicle){
        System.out.println(vehicle + "在天上飞。。。");
    }
}
